package java_作业4;

public class Main {
    public static void main(String[] args) {
        // 5. 父类引用子类实例
        Animal dog = new Dog();
        Animal cat = new Cat();

        Afraid afraidDog = new Dog();
        Afraid afraidCat = new Cat();

        Person person = new Person();

        // 调用方法
        System.out.println("-----喂养动物-----");
        person.feed(dog);
        person.feed(cat);

        System.out.println("\n-----捕捉动物-----");
        person.catchAnimal(afraidDog);
        System.out.println();
        person.catchAnimal(afraidCat);

        // 直接调用子类方法
        System.out.println("\n-----直接调用子类方法-----");
        dog.eat();
        cat.eat();
        afraidDog.escape();
        afraidCat.makeSounds();
    }
}